<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Eriloan 专业技术沙龙</title>
<script type="text/javascript" src="${pageContext.request.contextPath }/json2.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/jquery-1.7.2.js"></script>
</head>
<body>

<%-- <form action="${pageContext.request.contextPath }/user/test/eric" method="post" enctype="multipart/form-data"> --%>
<form action="${pageContext.request.contextPath }/user/test/eric" method="post">
	<input id="age" type="text" value="26" name="age"/><br>
	<input id="qt" type="text" value="3" name="qt"/><br>
	<input type="submit" value="表单方式提交"/>
</form>

<div id="qtd"></div>

<button onclick="subBtn('${pageContext.request.contextPath }/');">Ajax 提交</button>

<a href="#" style="height: 25px;width: 50px;border:1px solid red;">测试</a>
<span style="height: 25px;width: 100px;border:1px solid red;display: block;">测试</span>

<script type="text/javascript">
function subBtn(loginRootUrl){
	$.ajax({
		url : loginRootUrl + 'user/test/eric?time=' + Math.random(),
		data : 'age=' + $("#age").val()+'&qt='+$("#qt").val(),
		type : 'POST',
		dataType : 'json',
		success : function(data) {
	 		var jsonStr = JSON.stringify(data);
			json=$.parseJSON(jsonStr);
			$("#qtd").html(json.id);
		},
		error : function() {
			alert("出错了。");
		}
	});
}
</script>
</body>
</html>